package com.nine.demo.quartzdemo.controller;

import com.nine.demo.quartzdemo.job.TestJob;
import com.nine.demo.quartzdemo.service.QuartzService;
import org.quartz.*;
import org.quartz.impl.StdScheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author: 刘超
 * @Date: 2023-05-26 15:28
 */
@RestController
@RequestMapping("/quartz")
public class QuartzController {

    @Autowired
    QuartzService quartzService;

    @GetMapping("/start")
    public String start() throws SchedulerException {
        quartzService.start();
        return "start success";
    }

    @GetMapping("/stop")
    public String stop(){
        quartzService.stop();
        return "stop success";
    }

    @GetMapping("/pause")
    public String pause() throws SchedulerException {
        quartzService.pause();
        return "pause success";
    }

    @GetMapping("/resume")
    public String resume() throws SchedulerException {
        quartzService.resume();
        return "resume success";
    }

    @GetMapping("/delete")
    public String delete() throws SchedulerException {
        quartzService.delete();
        return "delete success";
    }

    @GetMapping("/add")
    public String add() throws SchedulerException {
        quartzService.add();
        return "add success";
    }

    @GetMapping("/triggerJob")
    public String triggerJob() throws SchedulerException {
        quartzService.triggerJob();
        return "triggerJob success";
    }




}
